package com.taobushi.service;

import com.taobushi.config.DS;
import com.taobushi.entity.User;
import com.taobushi.entity.User2;
import com.taobushi.mapper.User2Mapper;
import com.taobushi.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class TestService {
    @Autowired
    UserMapper userMapper;
    @Autowired
    User2Mapper user2Mapper;

    @Transactional
    @DS("masterDataSource")
    public List<User> getUserList(){
        List<User> userList = userMapper.getUserList();
        return userList;
    }
    @DS("slaveDataSource")
    @Transactional
    public List<User2> getUser2List(){
        List<User2> user2List = user2Mapper.getUserList();
        User2 user2 = new User2();
        user2.setId(6699);
        user2.setAge(1305);
        user2.setName("王晓名890");
        user2Mapper.insertUser2(user2);
        int a=67/0;
        return user2List;
    }
}
